extends AnimatedSprite2D

@onready var player = $".."
var is_flip = false
var cur_animate:String = "Idle"
var new_animate:String = ""
func anim_play():
	play("Mario_%s_%s" %[player.body_size,cur_animate])
	if player.direction == -1:
		is_flip = true
	elif player.direction == 1:
		is_flip = false
	flip_h = is_flip

# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
	if player.is_death:
		new_animate = "Death"
	elif player.is_shooting:
		new_animate = "Shoot"
	else:
		if not player.is_on_floor():
			new_animate = "Jump"
		elif player.direction == 0:
			if player.velocity.x == 0:
				new_animate = "Idle"
			else:
				new_animate = "Slide"
		else:
			new_animate = "Run"
	if cur_animate != new_animate:
		cur_animate = new_animate
		anim_play()
